use sandbox::invoke_client::InvokeClient;
use sandbox::upload_client::UploadClient;
use sandbox::{get_file_list_client, FileRequest, PythonRequest, UploadRequest};

use tonic::Request;
pub mod sandbox {
    tonic::include_proto!("sandbox");
}

#[tokio::main]

async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // let mut file = std::fs::OpenOptions::new()
    //     .read(true)
    //     .open("src/seir.py")
    //     .unwrap();
    // let mut buffer = Vec::new();
    // file.read_to_end(&mut buffer)?;
    // let mut client = UploadClient::connect("http://[::1]:50050").await.unwrap();
    // let request = Request::new(UploadRequest {
    //     user_name: "root".into(),
    //     file_name: "seir".into(),
    //     file_extensions: "py".into(),
    //     data: buffer,
    // });
    // let response = client.upload_file(request).await?;

    // println!("{:#?}", response);

    // let mut client = InvokeClient::connect("http://[::1]:50050").await.unwrap();
    // let request = Request::new(PythonRequest {
    //     filename: "02_SZ_DailyCases.csv".into(),
    //     username: "root".into(),
    // });
    // let response = client.seir_predict(request).await?;
    // println!("{:#?}", response);

    let mut client = get_file_list_client::GetFileListClient::connect("http://[::1]:50050")
        .await
        .unwrap();
    let request = Request::new(FileRequest {
        username: "root".into(),
    });
    let response = client.get_file_list(request).await?;
    println!("{:#?}", response);
    Ok(())
}
